import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

# 打开浏览器
service = Service(r'D:\Python3.14\chromedriver.exe')
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=service, options=chrome_options)   # 创建浏览器对象
# 输入访问网址
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大浏览器
driver.maximize_window()

"""ID选择器定位"""   # value="#id属性值"
# driver.find_element(by=By.CSS_SELECTOR, value="#userA").send_keys("admin")
# driver.find_element(By.CSS_SELECTOR, "#passwordA").send_keys("123456")

"""属性选择器"""     # value="[属性名='属性值']"
driver.find_element(by=By.CSS_SELECTOR, value="[name='telA']").send_keys("13633089805")

"""
类选择器
value=".class属性值"
注：多个class值，通过点号连接
"""
driver.find_element(by=By.CSS_SELECTOR, value=".emailA.dzyxA").send_keys("2218136327@qq.com")

"""元素选择器"""    # value="标签名"
# driver.find_element(by=By.CSS_SELECTOR, value="button").click()

"""
层级选择器
 根据元素的父子关系来选择元素  元素1>元素2
 根据元素的上下级来选择元素   元素1 元素2 
"""
# driver.find_element(by=By.CSS_SELECTOR, value="p>input").send_keys("admin")
driver.find_element(by=By.CSS_SELECTOR, value="form input").send_keys("test")

"""
其他选择器
利用局部属性值定位元素
标签名[属性名*='局部属性值']
"""
driver.find_element(By.CSS_SELECTOR, "input[id*='pass']").send_keys("123456")
